-- 社区惠购 · 业务扩展与角色初始化（独立执行脚本）
-- MySQL 8+, utf8mb4, InnoDB, 时区 Asia/Shanghai

SET NAMES utf8mb4;
SET time_zone = '+08:00';
SET FOREIGN_KEY_CHECKS = 0;

-- 角色：平台管理员/普通用户/团长/供应商
INSERT INTO `sys_role` (`role_id`, `role_name`, `role_key`, `role_sort`, `data_scope`, `status`, `create_by`)
VALUES
  (2001, '平台管理员', 'platform_admin', 1, '1', '0', 'system'),
  (2002, '普通用户',   'user',            2, '2', '0', 'system'),
  (2003, '团长',       'leader',          3, '2', '0', 'system'),
  (2004, '供应商',     'supplier',        4, '2', '0', 'system')
ON DUPLICATE KEY UPDATE role_name=VALUES(role_name), role_key=VALUES(role_key);

-- 管理员绑定平台管理员角色（如已存在则忽略）
INSERT IGNORE INTO `sys_user_role` (`user_id`,`role_id`) VALUES (1, 2001);

-- 如需将管理员密码重置为 '123456'，请在后端或使用安全脚本计算 bcrypt 哈希后再更新：
-- UPDATE sys_user SET password = '<bcrypt_of_123456>' WHERE user_id = 1;

-- ============ 核心业务表开始 ============

CREATE TABLE IF NOT EXISTS `ug_user_profile` (
  `user_id`           int       NOT NULL COMMENT 'sys_user.user_id',
  `openid`            varchar(64)  DEFAULT NULL COMMENT '小程序openid',
  `unionid`           varchar(64)  DEFAULT NULL COMMENT '微信unionid',
  `nickname`          varchar(50)  DEFAULT NULL,
  `avatar`            varchar(255) DEFAULT NULL,
  `gender`            tinyint      DEFAULT 2 COMMENT '0女 1男 2未知',
  `mobile`            varchar(20)  DEFAULT NULL,
  `default_leader_id` int          DEFAULT NULL COMMENT '默认团长',
  `inviter_user_id`   int          DEFAULT NULL COMMENT '邀请人',
  `create_time`       datetime(6)  DEFAULT CURRENT_TIMESTAMP(6),
  `update_time`       datetime(6)  DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
  PRIMARY KEY (`user_id`),
  KEY `idx_user_openid`(`openid`),
  KEY `idx_user_leader`(`default_leader_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户扩展档案';

CREATE TABLE IF NOT EXISTS `ug_leader` (
  `leader_id`     int NOT NULL AUTO_INCREMENT,
  `user_id`       int NOT NULL COMMENT '绑定sys_user',
  `real_name`     varchar(50)  NOT NULL,
  `mobile`        varchar(20)  NOT NULL,
  `community`     varchar(100) NOT NULL COMMENT '社区/小区名',
  `address`       varchar(255) NOT NULL,
  `lat`           decimal(10,6) DEFAULT NULL,
  `lng`           decimal(10,6) DEFAULT NULL,
  `wechat`        varchar(100)  DEFAULT NULL,
  `id_no`         varchar(32)   DEFAULT NULL COMMENT '身份证号(可脱敏/加密)',
  `commission_rate` decimal(5,2) NOT NULL DEFAULT 5.00 COMMENT '默认佣金比例%',
  `status`        tinyint NOT NULL DEFAULT 0 COMMENT '0待审 1通过 2拒绝 3禁用',
  `remark`        varchar(255) DEFAULT NULL,
  `create_time`   datetime(6) DEFAULT CURRENT_TIMESTAMP(6),
  `update_time`   datetime(6) DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
  PRIMARY KEY (`leader_id`),
  UNIQUE KEY `uk_leader_user` (`user_id`),
  KEY `idx_leader_status`(`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='团长';

CREATE TABLE IF NOT EXISTS `ug_supplier` (
  `supplier_id`   int NOT NULL AUTO_INCREMENT,
  `name`          varchar(100) NOT NULL,
  `contact`       varchar(50)  DEFAULT NULL,
  `mobile`        varchar(20)  DEFAULT NULL,
  `address`       varchar(255) DEFAULT NULL,
  `bank_name`     varchar(100) DEFAULT NULL,
  `bank_account`  varchar(64)  DEFAULT NULL,
  `settle_cycle`  varchar(20)  DEFAULT 'weekly' COMMENT 'weekly/monthly/custom',
  `status`        tinyint NOT NULL DEFAULT 1 COMMENT '1启用 0停用',
  `create_time`   datetime(6) DEFAULT CURRENT_TIMESTAMP(6),
  `update_time`   datetime(6) DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
  PRIMARY KEY (`supplier_id`),
  UNIQUE KEY `uk_supplier_name`(`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='供应商';

CREATE TABLE IF NOT EXISTS `ug_category` (
  `category_id` int NOT NULL AUTO_INCREMENT,
  `parent_id`   int DEFAULT 0,
  `name`        varchar(50) NOT NULL,
  `icon`        varchar(255) DEFAULT NULL,
  `sort`        int NOT NULL DEFAULT 0,
  `status`      tinyint NOT NULL DEFAULT 1,
  PRIMARY KEY (`category_id`),
  KEY `idx_cat_parent`(`parent_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商品分类';

CREATE TABLE IF NOT EXISTS `ug_goods` (
  `goods_id`     int NOT NULL AUTO_INCREMENT,
  `supplier_id`  int NOT NULL,
  `category_id`  int NOT NULL,
  `title`        varchar(120) NOT NULL,
  `subtitle`     varchar(255) DEFAULT NULL,
  `cover`        varchar(255) DEFAULT NULL,
  `desc_html`    mediumtext,
  `status`       tinyint NOT NULL DEFAULT 1 COMMENT '1上架 0下架',
  `audit_status` tinyint NOT NULL DEFAULT 1 COMMENT '1通过 0待审 2拒绝',
  `sales`        int NOT NULL DEFAULT 0,
  `create_time`  datetime(6) DEFAULT CURRENT_TIMESTAMP(6),
  `update_time`  datetime(6) DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
  PRIMARY KEY (`goods_id`),
  KEY `idx_goods_supplier`(`supplier_id`),
  KEY `idx_goods_category`(`category_id`),
  KEY `idx_goods_status`(`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商品';

CREATE TABLE IF NOT EXISTS `ug_sku` (
  `sku_id`       int NOT NULL AUTO_INCREMENT,
  `goods_id`     int NOT NULL,
  `spec_json`    json DEFAULT NULL COMMENT '规格JSON',
  `price`        decimal(10,2) NOT NULL,
  `origin_price` decimal(10,2) DEFAULT NULL,
  `stock`        int NOT NULL DEFAULT 0,
  `barcode`      varchar(64) DEFAULT NULL,
  `weight`       decimal(10,2) DEFAULT NULL,
  `status`       tinyint NOT NULL DEFAULT 1,
  PRIMARY KEY (`sku_id`),
  KEY `idx_sku_goods`(`goods_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商品SKU';

CREATE TABLE IF NOT EXISTS `ug_stock_log` (
  `id`        bigint NOT NULL AUTO_INCREMENT,
  `sku_id`    int    NOT NULL,
  `change`    int    NOT NULL COMMENT '变动数量（正加负减）',
  `biz_type`  varchar(30) NOT NULL COMMENT 'order/create/refund/manual',
  `biz_no`    varchar(64) DEFAULT NULL,
  `remark`    varchar(255) DEFAULT NULL,
  `create_time` datetime(6) DEFAULT CURRENT_TIMESTAMP(6),
  PRIMARY KEY (`id`),
  KEY `idx_stock_sku`(`sku_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='库存流水';

CREATE TABLE IF NOT EXISTS `ug_cart` (
  `id`        bigint NOT NULL AUTO_INCREMENT,
  `user_id`   int NOT NULL,
  `sku_id`    int NOT NULL,
  `quantity`  int NOT NULL DEFAULT 1,
  `checked`   tinyint NOT NULL DEFAULT 1,
  `create_time` datetime(6) DEFAULT CURRENT_TIMESTAMP(6),
  `update_time` datetime(6) DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_cart_user_sku` (`user_id`,`sku_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='购物车';

CREATE TABLE IF NOT EXISTS `ug_order` (
  `order_id`     bigint NOT NULL AUTO_INCREMENT,
  `order_no`     varchar(40) NOT NULL,
  `user_id`      int NOT NULL,
  `leader_id`    int DEFAULT NULL COMMENT '自提点/团长',
  `amount_goods` decimal(10,2) NOT NULL DEFAULT 0.00,
  `amount_freight` decimal(10,2) NOT NULL DEFAULT 0.00,
  `amount_discount` decimal(10,2) NOT NULL DEFAULT 0.00,
  `amount_payable` decimal(10,2) NOT NULL DEFAULT 0.00,
  `amount_paid`  decimal(10,2) NOT NULL DEFAULT 0.00,
  `pay_status`   tinyint NOT NULL DEFAULT 0 COMMENT '0未支付 1已支付 2已退款',
  `order_status` tinyint NOT NULL DEFAULT 0 COMMENT '0待支付 1待发货 2待自提/待收货 3已完成 4已关闭',
  `delivery_type` tinyint NOT NULL DEFAULT 1 COMMENT '1自提(团长) 2配送',
  `receiver_snapshot` json DEFAULT NULL COMMENT '收货/自提信息快照',
  `remark`       varchar(255) DEFAULT NULL,
  `create_time`  datetime(6) DEFAULT CURRENT_TIMESTAMP(6),
  `pay_time`     datetime(6) DEFAULT NULL,
  `finish_time`  datetime(6) DEFAULT NULL,
  `close_time`   datetime(6) DEFAULT NULL,
  PRIMARY KEY (`order_id`),
  UNIQUE KEY `uk_order_no`(`order_no`),
  KEY `idx_order_user`(`user_id`),
  KEY `idx_order_leader`(`leader_id`),
  KEY `idx_order_status`(`order_status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='订单主表';

CREATE TABLE IF NOT EXISTS `ug_order_item` (
  `id`         bigint NOT NULL AUTO_INCREMENT,
  `order_id`   bigint NOT NULL,
  `goods_id`   int    NOT NULL,
  `sku_id`     int    NOT NULL,
  `title`      varchar(120) NOT NULL,
  `spec_json`  json DEFAULT NULL,
  `price`      decimal(10,2) NOT NULL,
  `quantity`   int NOT NULL,
  `amount`     decimal(10,2) NOT NULL,
  `refund_status` tinyint NOT NULL DEFAULT 0 COMMENT '0无 1申请中 2部分 3全部',
  PRIMARY KEY (`id`),
  KEY `idx_item_order`(`order_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='订单明细';

CREATE TABLE IF NOT EXISTS `ug_payment` (
  `id`          bigint NOT NULL AUTO_INCREMENT,
  `order_id`    bigint NOT NULL,
  `pay_no`      varchar(50) NOT NULL COMMENT '支付单号',
  `channel`     varchar(20) NOT NULL COMMENT 'wxpay/alipay/offline',
  `amount`      decimal(10,2) NOT NULL,
  `status`      tinyint NOT NULL DEFAULT 0 COMMENT '0待支付 1成功 2失败',
  `paid_at`     datetime(6) DEFAULT NULL,
  `transaction_id` varchar(80) DEFAULT NULL,
  `create_time` datetime(6) DEFAULT CURRENT_TIMESTAMP(6),
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_payment_payno`(`pay_no`),
  KEY `idx_payment_order`(`order_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='支付记录';

CREATE TABLE IF NOT EXISTS `ug_refund` (
  `id`          bigint NOT NULL AUTO_INCREMENT,
  `order_id`    bigint NOT NULL,
  `order_item_id` bigint DEFAULT NULL,
  `refund_no`   varchar(50) NOT NULL,
  `amount`      decimal(10,2) NOT NULL,
  `reason`      varchar(255) DEFAULT NULL,
  `status`      tinyint NOT NULL DEFAULT 0 COMMENT '0申请 1成功 2拒绝 3关闭',
  `created_by`  int DEFAULT NULL,
  `create_time` datetime(6) DEFAULT CURRENT_TIMESTAMP(6),
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_refund_no`(`refund_no`),
  KEY `idx_refund_order`(`order_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='退款记录';

CREATE TABLE IF NOT EXISTS `ug_pickup_code` (
  `id`        bigint NOT NULL AUTO_INCREMENT,
  `order_id`  bigint NOT NULL,
  `code`      varchar(12) NOT NULL,
  `status`    tinyint NOT NULL DEFAULT 0 COMMENT '0未核销 1已核销',
  `verify_time` datetime(6) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_pickup_code`(`code`),
  KEY `idx_pickup_order`(`order_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='自提核销码';

CREATE TABLE IF NOT EXISTS `ug_commission` (
  `id`          bigint NOT NULL AUTO_INCREMENT,
  `leader_id`   int NOT NULL,
  `order_id`    bigint NOT NULL,
  `order_item_id` bigint DEFAULT NULL,
  `amount`      decimal(10,2) NOT NULL,
  `rate`        decimal(5,2) NOT NULL,
  `status`      tinyint NOT NULL DEFAULT 0 COMMENT '0未结算 1已结算',
  `create_time` datetime(6) DEFAULT CURRENT_TIMESTAMP(6),
  PRIMARY KEY (`id`),
  KEY `idx_commission_leader`(`leader_id`),
  KEY `idx_commission_order`(`order_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='团长佣金明细';

CREATE TABLE IF NOT EXISTS `ug_settlement` (
  `settle_id`   bigint NOT NULL AUTO_INCREMENT,
  `leader_id`   int NOT NULL,
  `period`      varchar(20) NOT NULL COMMENT '结算周期 e.g. 2025W33 或 2025-08',
  `amount_total` decimal(10,2) NOT NULL DEFAULT 0.00,
  `amount_paid`  decimal(10,2) NOT NULL DEFAULT 0.00,
  `status`      tinyint NOT NULL DEFAULT 0 COMMENT '0待确认 1待打款 2已打款',
  `create_time` datetime(6) DEFAULT CURRENT_TIMESTAMP(6),
  `pay_time`    datetime(6) DEFAULT NULL,
  PRIMARY KEY (`settle_id`),
  UNIQUE KEY `uk_settle_leader_period`(`leader_id`,`period`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='团长结算';

CREATE TABLE IF NOT EXISTS `ug_address` (
  `id`        int NOT NULL AUTO_INCREMENT,
  `user_id`   int NOT NULL,
  `name`      varchar(50)  NOT NULL,
  `mobile`    varchar(20)  NOT NULL,
  `province`  varchar(50)  NOT NULL,
  `city`      varchar(50)  NOT NULL,
  `district`  varchar(50)  NOT NULL,
  `detail`    varchar(255) NOT NULL,
  `is_default` tinyint NOT NULL DEFAULT 0,
  `create_time` datetime(6) DEFAULT CURRENT_TIMESTAMP(6),
  PRIMARY KEY (`id`),
  KEY `idx_addr_user`(`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户收货地址';

-- ============ 核心业务表结束 ============

-- ============ 菜单与权限（供应商管理）开始 ============
-- 说明：依赖系统已存在的 sys_menu/sys_role_menu 结构，menu_id 从 2000 起避开系统保留段

-- 菜单：社区惠购 目录 + 供应商管理 页面 + 功能按钮
BEGIN;
INSERT INTO `sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`, `del_flag`) VALUES
  (2000, '社区惠购', 0, 1, 'ug', NULL, '', '1', '0', 'M', '0', '0', '', 'shopping', 'system', NOW(6), '', NULL, '社区惠购目录', '0')
ON DUPLICATE KEY UPDATE menu_name=VALUES(menu_name), path=VALUES(path), menu_type=VALUES(menu_type), perms=VALUES(perms);

INSERT INTO `sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`, `del_flag`) VALUES
  (2001, '供应商管理', 2000, 1, 'supplier', 'ug/supplier/index', '', '1', '0', 'C', '0', '0', 'ug:supplier:list', 'tree', 'system', NOW(6), '', NULL, '供应商管理菜单', '0')
ON DUPLICATE KEY UPDATE menu_name=VALUES(menu_name), parent_id=VALUES(parent_id), path=VALUES(path), component=VALUES(component), perms=VALUES(perms);

INSERT INTO `sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`, `del_flag`) VALUES
  (2002, '供应商查询', 2001, 1, '', '', '', '1', '0', 'F', '0', '0', 'ug:supplier:query', '#', 'system', NOW(6), '', NULL, '', '0'),
  (2003, '供应商新增', 2001, 2, '', '', '', '1', '0', 'F', '0', '0', 'ug:supplier:add', '#', 'system', NOW(6), '', NULL, '', '0'),
  (2004, '供应商修改', 2001, 3, '', '', '', '1', '0', 'F', '0', '0', 'ug:supplier:edit', '#', 'system', NOW(6), '', NULL, '', '0'),
  (2005, '供应商删除', 2001, 4, '', '', '', '1', '0', 'F', '0', '0', 'ug:supplier:remove', '#', 'system', NOW(6), '', NULL, '', '0')
ON DUPLICATE KEY UPDATE menu_name=VALUES(menu_name), parent_id=VALUES(parent_id), perms=VALUES(perms);
COMMIT;

-- 将供应商菜单授权给平台管理员角色（2001）
BEGIN;
INSERT IGNORE INTO `sys_role_menu` (`role_id`, `menu_id`) VALUES
  (2001, 2000), (2001, 2001), (2001, 2002), (2001, 2003), (2001, 2004), (2001, 2005);
COMMIT;
-- ============ 菜单与权限（供应商管理）结束 ============

-- ============ 菜单与权限（分类管理）开始 ============
-- 说明：与供应商同级，menu_id 采用 2010+ 避免冲突
BEGIN;
INSERT INTO `sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`, `del_flag`) VALUES
  (2010, '分类管理', 2000, 2, 'category', 'ug/category/index', '', '1', '0', 'C', '0', '0', 'ug:category:list', 'list', 'system', NOW(6), '', NULL, '分类管理菜单', '0')
ON DUPLICATE KEY UPDATE menu_name=VALUES(menu_name), parent_id=VALUES(parent_id), path=VALUES(path), component=VALUES(component), perms=VALUES(perms);

INSERT INTO `sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`, `del_flag`) VALUES
  (2011, '分类查询', 2010, 1, '', '', '', '1', '0', 'F', '0', '0', 'ug:category:query', '#', 'system', NOW(6), '', NULL, '', '0'),
  (2012, '分类新增', 2010, 2, '', '', '', '1', '0', 'F', '0', '0', 'ug:category:add',   '#', 'system', NOW(6), '', NULL, '', '0'),
  (2013, '分类修改', 2010, 3, '', '', '', '1', '0', 'F', '0', '0', 'ug:category:edit',  '#', 'system', NOW(6), '', NULL, '', '0'),
  (2014, '分类删除', 2010, 4, '', '', '', '1', '0', 'F', '0', '0', 'ug:category:remove','#', 'system', NOW(6), '', NULL, '', '0')
ON DUPLICATE KEY UPDATE menu_name=VALUES(menu_name), parent_id=VALUES(parent_id), perms=VALUES(perms);
COMMIT;

-- 将分类菜单授权给平台管理员角色（2001）
BEGIN;
INSERT IGNORE INTO `sys_role_menu` (`role_id`, `menu_id`) VALUES
  (2001, 2010), (2001, 2011), (2001, 2012), (2001, 2013), (2001, 2014);
COMMIT;
-- ============ 菜单与权限（分类管理）结束 ============

-- ============ 菜单与权限（商品管理）开始 ============
-- 说明：与供应商/分类同级，menu_id 采用 2020+ 避免冲突
BEGIN;
INSERT INTO `sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`, `del_flag`) VALUES
  (2020, '商品管理', 2000, 3, 'goods', 'ug/goods/index', '', '1', '0', 'C', '0', '0', 'ug:goods:list', 'shopping', 'system', NOW(6), '', NULL, '商品管理菜单', '0')
ON DUPLICATE KEY UPDATE menu_name=VALUES(menu_name), parent_id=VALUES(parent_id), path=VALUES(path), component=VALUES(component), perms=VALUES(perms);

INSERT INTO `sys_menu` (`menu_id`, `menu_name`, `parent_id`, `order_num`, `path`, `component`, `query`, `is_frame`, `is_cache`, `menu_type`, `visible`, `status`, `perms`, `icon`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`, `del_flag`) VALUES
  (2021, '商品查询', 2020, 1, '', '', '', '1', '0', 'F', '0', '0', 'ug:goods:query',  '#', 'system', NOW(6), '', NULL, '', '0'),
  (2022, '商品新增', 2020, 2, '', '', '', '1', '0', 'F', '0', '0', 'ug:goods:add',    '#', 'system', NOW(6), '', NULL, '', '0'),
  (2023, '商品修改', 2020, 3, '', '', '', '1', '0', 'F', '0', '0', 'ug:goods:edit',   '#', 'system', NOW(6), '', NULL, '', '0'),
  (2024, '商品删除', 2020, 4, '', '', '', '1', '0', 'F', '0', '0', 'ug:goods:remove', '#', 'system', NOW(6), '', NULL, '', '0'),
  (2025, '商品审核', 2020, 5, '', '', '', '1', '0', 'F', '0', '0', 'ug:goods:audit',  '#', 'system', NOW(6), '', NULL, '', '0')
ON DUPLICATE KEY UPDATE menu_name=VALUES(menu_name), parent_id=VALUES(parent_id), perms=VALUES(perms);
COMMIT;

-- 将商品菜单授权给平台管理员角色（2001）
BEGIN;
INSERT IGNORE INTO `sys_role_menu` (`role_id`, `menu_id`) VALUES
  (2001, 2020), (2001, 2021), (2001, 2022), (2001, 2023), (2001, 2024), (2001, 2025);
COMMIT;
-- ============ 菜单与权限（商品管理）结束 ============

SET FOREIGN_KEY_CHECKS = 1;

